This XFCN will take any value up to about 190 chars long and strip all chars except a leading minus sign 0 - 9 and a decimal point. It will return a formatted number with or without a dollar sign and with a specified number of decimal places in the form: (-)($)###,###,###(.)#####. It will pad the number with zeros or truncate it, depending on the number of decimal places specified.
This is free. All I ask is to be notified of any suggestions or bugs found, and a credit line if you use it in released stacks. LightSpeed C source available on request.
Copyright 1988. All rights reserved.
Dwight Mayo
GEnie, MacNet - DMAYO
Compuserve - 76257,3303
-- part contents for background part 27
----- text -----
XFCN
-- part contents for background part 7
----- text -----
Syntax:
formatNum(Value,DollarSign,NumberofDecimals)
Value can be any char and up to 190 chars long. formatNum will strip any char that is not a negative sign or a number (between 0 and 9) and will return a positive or negative formatted number.
NOTE: You must include the negative sign if this is to be a negative number (e.g.,-123).
If DollarSign is zero or left out, then no "$" wil be included.
If DollarSign is a 1, then a "$" will be included.
If NumberofDecimals is zero or left out, then no "." will be included, and any characters after the decimal you have in the string will be gone as well. This is also how you do truncating (i.e., if your begining number is 12345.12345 and you specify three decimal places, the returned number will be 12345.123).
If NumberofDecimals is greater then zero, you will get that many decimal places. If you don't include enough characters, then the return string will be padded with zeros.